home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 3 / Amiga Tools 3.iso / grafik / raytracing / rayshade-4.0.6.3 / libray / libcommon / translate.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-09  |  1.9 KB  |  81 lines

  1. /*
  2.  * translate.c
  3.  *
  4.  * Copyright (C) 1989, 1991, Craig E. Kolb
  5.  * All rights reserved.
  6.  *
  7.  * This software may be freely copied, modified, and redistributed
  8.  * provided that this copyright notice is preserved on all copies.
  9.  *
  10.  * You may not distribute this software, in whole or in part, as part of
  11.  * any commercial product without the express consent of the authors.
  12.  * 
  13.  * There is no warranty or other guarantee of fitness of this software
  14.  * for any purpose.  It is provided solely "as is".
  15.  *
  16.  * translate.c,v 4.1 1994/08/09 07:55:22 explorer Exp
  17.  *
  18.  * translate.c,v
  19.  * Revision 4.1  1994/08/09  07:55:22  explorer
  20.  * Bump version to 4.1
  21.  *
  22.  * Revision 1.1.1.1  1994/08/08  04:52:02  explorer
  23.  * Initial import.  This is a prerelease of 4.0.6enh3, or 4.1 possibly.
  24.  *
  25.  * Revision 4.0  91/07/17  14:32:42  kolb
  26.  * Initial version.
  27.  * 
  28.  */
  29. #include "common.h"
  30. #include "translate.h"
  31.  
  32. TransMethods *iTranslateMethods;
  33. void TranslationMatrix();
  34.  
  35. Translate *
  36. TranslateCreate()
  37. {
  38.     Translate *res;
  39.  
  40.     res = (Translate *)Malloc(sizeof(Translate));
  41.     res->x = res->y = res->z = 0.;
  42.     return res;
  43. }
  44.  
  45. TransMethods *
  46. TranslateMethods()
  47. {
  48.     if (iTranslateMethods == (TransMethods *)NULL) {
  49.         iTranslateMethods = (TransMethods *)Malloc(sizeof(TransMethods));
  50.         iTranslateMethods->create = (TransCreateFunc *)TranslateCreate;
  51.         iTranslateMethods->propagate = TranslatePropagate;
  52.     }
  53.     return iTranslateMethods;    
  54. }
  55.  
  56. void
  57. TranslatePropagate(translate, trans, itrans)
  58. Translate *translate;
  59. RSMatrix *trans, *itrans;
  60. {
  61.     TranslationMatrix(translate->x, translate->y, translate->z, trans);
  62.     /*
  63.      * Build the inverse...
  64.      */
  65.     MatrixInit(itrans);
  66.     itrans->translate.x = -translate->x;
  67.     itrans->translate.y = -translate->y;
  68.     itrans->translate.z = -translate->z;
  69. }
  70.  
  71. void
  72. TranslationMatrix(x, y, z, mat)
  73. Float x, y, z;
  74. RSMatrix *mat;
  75. {
  76.     MatrixInit(mat);
  77.     mat->translate.x = x;
  78.     mat->translate.y = y;
  79.     mat->translate.z = z;
  80. }
  81.